package com.silverbox.shopper.service.order.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.silverbox.shopper.entity.CupboardOrderRecord;
import com.silverbox.shopper.entity.RelMachineHardWare;
import com.silverbox.shopper.mapper.CupboardOrderRecordMapper;
import com.silverbox.shopper.mapper.InvoiceMapper;
import com.silverbox.shopper.mapper.OrderMapper;
import com.silverbox.shopper.mapper.RelMachineHardWareMapper;
import com.silverbox.shopper.service.order.OrderService;

@Service
public class OrderServiceImpl implements OrderService {

	@Autowired
	private OrderMapper orderMapper;
	
	@Autowired
	private CupboardOrderRecordMapper cupboardOrderRecordMapper;
	
	@Autowired
	private RelMachineHardWareMapper relMachineHardWareMapper;
	
	@Autowired
	private InvoiceMapper invoiceMapper;
	
	@Override
	public Integer updateAndGetOrderSeq(Integer storeId, Integer orderType) {
		return orderMapper.updateAndGetOrderSeq(storeId,orderType);
	}

	@Override
	public List<CupboardOrderRecord> getOnlineMealRecordByNum(CupboardOrderRecord orderRecord) {
		return cupboardOrderRecordMapper.getOnlineMealRecordByNum(orderRecord);
	}

	@Override
	public RelMachineHardWare getMachineHardWareInfo(RelMachineHardWare machineHard) {
		return relMachineHardWareMapper.getMachineHardWareInfo(machineHard);
	}

	@Override
	public int saveCupboardOrderRecord(CupboardOrderRecord orderRecord) {
		return cupboardOrderRecordMapper.insertSelective(orderRecord);
	}

	@Override
	public List<CupboardOrderRecord> getCupboardGoodsStatus(String orderNum, Long itemId,Date createTime) {
		return cupboardOrderRecordMapper.getCupboardGoodsStatus(orderNum,itemId,createTime);
	}

	@Override
	public boolean isOpenInvoice(Integer storeId, String orderNum) {
		Integer count = invoiceMapper.getIsOpenInvoice(storeId, orderNum);
		if(count > 0){
			return true;	
		}else{
			return false;	
		}
	}

}
